package com.example.config;

import com.example.service.UserService;
import org.flowable.idm.api.User;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 自定义用户实体管理器
 * 用于集成外部用户系统
 */
@Component
public class CustomUserEntityManager {
    
    // 注入您的用户服务
    @Autowired
    private UserService userService;
    
    public User findUserById(String userId) {
        // 调用外部用户服务获取用户信息
        UserService.User user = userService.findUserById(userId);
        if (user != null) {
            UserEntityImpl flowableUser = new UserEntityImpl();
            flowableUser.setId(user.getId());
            flowableUser.setFirstName(user.getName());
            flowableUser.setLastName(user.getLastName());
            flowableUser.setEmail(user.getEmail());
            return flowableUser;
        }
        
        return null;
    }
}